import unittest


class DemoTestCase(unittest.TestCase):
    # 无条件跳过装饰的测试用例, 并说明跳过测试用例的原因
    @unittest.skip('跳过用例的原因01')
    def test01(self):
        print('test01')

    # 条件为真时, 跳过装饰的用例
    @unittest.skipIf(1 == 2, '跳过用例的原因02')
    def test02(self):
        print('test02')

    # 条件为假时, 跳过装饰的用例
    @unittest.skipUnless(1 == 2, '跳过用例的原因03')
    def test03(self):
        print('test03')

    # 预期该测试用例会失败,跳过它
    @unittest.expectedFailure
    def test04(self):
        self.assertEqual(1, 2, '断言失败')


if __name__ == '__main__':
    unittest.main(verbosity=2)
